package com.softer.wxzj.controller;


import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.DicContent;
import com.softer.wxzj.service.DicContentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * DiccontentController class
 *
 * @author wxr
 * @date 2019/4/10
 */
@RestController
@RequestMapping("/diccontent")
@Slf4j
public class DicContentController {
    @Autowired
    DicContentService diccontentService;

    /**
     * 字典内容添加
     *
     * @param f
     * @return
     */
    @RequestMapping("/add")
    @LogRecord(description = "字典内容添加", operationUnit = LogOperationUnit.DIC_CONTENT, operationType = LogOperationType.INSERT)
    public CommonResult add(DicContent f) {
        return diccontentService.insert(f);
    }

    /**
     * 字典内容修改
     *
     * @param f
     * @return
     */
    @RequestMapping("/update")
    @LogRecord(description = "字典内容修改", operationUnit = LogOperationUnit.DIC_CONTENT, operationType = LogOperationType.UPDATE)
    public CommonResult update(DicContent f) {
        return diccontentService.update(f);
    }

    /**
     * 字典内容删除
     *
     * @param id
     * @return
     */
    @RequestMapping("/delete")
    @LogRecord(description = "字典内容删除", operationUnit = LogOperationUnit.DIC_CONTENT, operationType = LogOperationType.DELETE)
    public CommonResult delete(String id) {
        return diccontentService.delete(id);
    }

    /**
     * 字典内容列表查询
     *
     * @param page
     * @param f
     * @return
     */
    @RequestMapping("/getList")
    @LogRecord(description = "字典内容列表查询", operationUnit = LogOperationUnit.DIC_CONTENT, operationType = LogOperationType.SELECT)
    public PageInfo<DicContent> getList(Page page, DicContent f) {
        return diccontentService.getList(page, f);
    }

    /**
     * 查询审批流程类型详情
     *
     * @param id
     * @return
     */
    @RequestMapping("/getInfo")
    @LogRecord(description = "查询审批流程类型详情", operationUnit = LogOperationUnit.DIC_CONTENT, operationType = LogOperationType.SELECT)
    public DicContent getInfo(String id) {
        return diccontentService.getInfo(id);
    }

    /**
     * getListbyDicCode
     *
     * @param diccontent
     * @return
     */
    @RequestMapping("/getListbyDicCode")
    @LogRecord(description = "根据字典类型查询字典信息列表", operationUnit = LogOperationUnit.DIC_CONTENT, operationType = LogOperationType.SELECT)
    public PageInfo<DicContent> getListbyDicCode(Page page,DicContent diccontent) {
        return diccontentService.getListbyDicCode(page,diccontent);
    }

    @RequestMapping("/selectForInput")
    @LogRecord(description = "前端查询菜单", operationUnit = LogOperationUnit.DIC_CONTENT, operationType = LogOperationType.SELECT)
    public List<DicContent> selectForInput(String dicType) {
        return diccontentService.selectForInput(dicType);
    }

    @RequestMapping("/fuzzySearch")
    @LogRecord(description = "模糊查询查询角色", operationUnit = LogOperationUnit.DIC_CONTENT, operationType = LogOperationType.SELECT)
    public PageInfo<DicContent> fuzzySearch(Page page, String fuzzy, String typeId) {
        return diccontentService.fuzzySearch(page, fuzzy, typeId);
    }

    /**
     * 根据字典类型查询字典详情
     *
     * @param dicType 字典类型
     * @return 字典详情
     */
    @RequestMapping("/getListByDicType")
    @LogRecord(description = "根据字典类型查询字典详情", operationUnit = LogOperationUnit.DIC_CONTENT, operationType = LogOperationType.SELECT)
    public List<DicContent> getListByDicType(String dicType) {
        return diccontentService.getListByDicType(dicType);
    }

    /**
     * 查询外网注册类型列表
     *
     * @return 外网注册类型列表
     */
    @RequestMapping("/getRegisterType")
    @LogRecord(description = "查询外网注册类型列表", operationUnit = LogOperationUnit.DIC_CONTENT, operationType = LogOperationType.SELECT)
    public List<DicContent> getRegisterType() {
        return diccontentService.getRegisterType();
    }
}
